/*--------------参数下拉-------------------*/
/*数字引脚*/
enum SZ_YINJIAO {2,3,4,9,10,11,12,13,A0,A1,A2,A3}
/*PWM引脚*/
enum PWM_YINJIAO {3,9,10,11}
/*模拟引脚*/
enum MN_YINJIAO {A0,A1,A2,A3}
/*数字传感器有无信号下拉*/
enum YOUWU {
    //% block="有信号"
    0,
    //% block="无信号"
    1
}
/*超声波引脚*/
enum trig {2,3,4,9,10,11,12,13,A0,A1,A2,A3,
    //% block="A4(SDA)"
    A4,
    //% block="A5(SCL)"
    A5,
}
enum echo {2,3,4,9,10,11,12,13,A0,A1,A2,A3,
    //% block="A4(SDA)"
    A4,
    //% block="A5(SCL)"
    A5,
}
/*tm1637四位数码管*/
enum Clk {2,3,4,9,10,11,12,13,A0,A1,A2,A3,
    //% block="A4(SDA)"
    A4,
    //% block="A5(SCL)"
    A5,
}
enum Dio {2,3,4,9,10,11,12,13,A0,A1,A2,A3,
    //% block="A4(SDA)"
    A4,
    //% block="A5(SCL)"
    A5,
}
enum TM1637_caozuo {
    //% block="开"
    on,
    //% block="关"
    off,
    //% block="清屏"
    clear,
    //% block="闪烁"
    blink
}
enum TM1637_ShiZhongDian {
    //% block="开"
    true,
    //% block="关"
    false,
}
/*温湿度传感器下拉*/
enum WenShiDu_DHT {
    //% block="DHT11"
    1,
    //% block="DHT22"
    2
}
enum WenShiDu {
    //% block="温度(℃)"
    getTemperature,
    //% block="湿度(%rh)"
    getHumidity
}
enum YAN_SE {红色,绿色,蓝色}
enum RGB {
    R,G,B
}
//RGB灯移动
enum RGB_xh_yd {
    //% block="移动"
    0,
    //% block="循环移动"
    1
}
/*LCD1602下拉*/
enum Y1602 {
    //% block="上面一行"
    0,
    //% block="下面一行"
    1,
}
/*------OTP语音播放模块下拉菜单-------*/

enum OTP_yinliang 
{
    //% block="1"
    1,
    //% block="2"
    2,
    //% block="3"
    3,
    //% block="4"
    4,
    //% block="5"
    5,
    //% block="6"
    6,
    //% block="7"
    7,
    //% block="8"
    8,
}
enum OTP_shezhi 
{
    //% block="循环播放"
    0xF2,
    //% block="停止播放" //播放下一段语音或使用停止指令结束循环
    0xFE,
    //% block="(需要循环播放的语音放在循环模块上方，等待时间设为0）"
    1111,
    //% block="(播放下一段语音或使用停止指令结束循环）"
    1112,
}
//语音模块下拉
enum BOFANG_CY {
    //% block="老师"
    0,
    //% block="爸爸"
    1,
    //% block="妈妈"
    2,
    //% block="爷爷"
    3,
    //% block="奶奶"
    4,
    //% block="姥姥"
    5,
    //% block="姥爷"
    6,
    //% block="哥哥"
    7,
    //% block="姐姐"
    8,
    //% block="叔叔"
    9,
    //% block="阿姨"
    10,
    //% block="新年快乐"
    16,
    //% block="身体健康"
    17,
    //% block="工作顺利"
    18,
    //% block="学习进步"
    19,
    //% block="您好"
    20,
    //% block="谢谢"
    21,
    //% block="的"
    22,
    //% block="祝"
    23,
    //% block="慢走"
    24,
    //% block="欢迎光临"
    25,
    //% block="亲爱的"
    26,
    //% block="同学们"
    27,
    //% block="工作辛苦了"
    28,
    //% block="打开"
    30,
    //% block="关闭"
    31,
    //% block="当前"
    45,
    //% block="转"
    46,
    //% block="左"
    47,
    //% block="右"
    48,
    //% block="请"
    49,
    //% block="已"
    50,
    //% block="现在"
    51,
    //% block="是"
    52,
    //% block="红灯"
    53,
    //% block="绿灯"
    54,
    //% block="黄灯"
    55,
    //% block="欢迎常来"
    58,
    //% block="还有"
    59,
    //% block="变"
    62,
    //% block="等"
    63,
    //% block="下一次"
    64,
    //% block="功能"
    65,
    //% block="障碍物"
    66,
    //% block="世界那么大，我想去看看"
    67,
    //% block="上"
    112,
    //% block="下"
    113,
    //% block="接近"
    114,
    //% block="远离"
    115,
    //% block="灯"
    116,
    //% block="风扇"
    117,
    //% block="红色"
    118,
    //% block="绿色"
    119,
    //% block="蓝色"
    120,
    //% block="黄色"
    121,
    //% block="白色"
    122,
    //% block="叮-音效"
    123,
    //% block="滴滴滴-闹铃音效"
    124,
    //% block="叮叮叮叮升-音效"
    125,
    //% block="叮叮叮叮降-音效"
    126,
}
enum BOFANG_SJ {
    //% block="秒"
    60,
    //% block="分"
    61,
    //% block="点"
    29,
    //% block="今天"
    68,
    //% block="明天"
    81,
    //% block="年"
    69,
    //% block="月"
    70,
    //% block="日"
    71,
    //% block="星期"
    72,
    //% block="农历"
    73,
    //% block="现在时刻"
    74,
    //% block="北京时间"
    75,
    //% block="整"
    76,
    //% block="百分之"
    78,
    //% block="距离"
    79,
    //% block="上午"
    11,
    //% block="下午"
    12,
    //% block="晚上"
    13,
    //% block="前方"
    14,
    //% block="厘米"
    15,
    //% block="千"
    32,
    //% block="百"
    33,
    //% block="十/时"
    34,
    //% block="1"
    35,
    //% block="2"
    36,
    //% block="3"
    37,
    //% block="4"
    38,
    //% block="5"
    39,
    //% block="6"
    40,
    //% block="7"
    41,
    //% block="8"
    42,
    //% block="9"
    43,
    //% block="0"
    44,
}
enum BOFANG_TQ {
    //% block="温度"
    56,
    //% block="湿度"
    57,
    //% block="度"
    77,
    //% block="天气"
    82,
    //% block="白天"
    83,
    //% block="夜间"
    84,
    //% block="晴"
    85,
    //% block="多云"
    86,
    //% block="阴"
    87,
    //% block="雨"
    88,
    //% block="雷阵"
    89,
    //% block="小"
    90,
    //% block="中"
    91,
    //% block="大"
    92,
    //% block="夹"
    93,
    //% block="雪"
    94,
    //% block="雾"
    95,
    //% block="霾"
    96,
    //% block="风"
    97,
    //% block="东"
    98,
    //% block="南"
    99,
    //% block="西"
    100,
    //% block="北"
    101,
    //% block="到"
    102,
    //% block="级"
    103,
    //% block="偏"
    104,
    //% block="方向"
    105,
    //% block="空气质量"
    106,
    //% block="优"
    107,
    //% block="良"
    108,
    //% block="轻度污染"
    109,
    //% block="中度污染"
    110,
    //% block="重度污染"
    111,
}

//% color="#FF8C00" iconWidth=40 iconHeight=40 /*图标颜色#D89048*/
namespace LBXQ2 
{

    //--------------语音播放模块-------------------//

    //% block="初始化 语音播放模块 引脚[SZ_YINJIAO]" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    export function OTPyuyin_CSH(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;

        //Generator.addInclude('YUYIN', '#include <YUYIN.h>');//也可以使用
        Generator.addInclude('LBXQ_2', '#include <LBXQ_2.h>');//统一分类到LBXQ
        Generator.addObject( `MP3BF`, `MP3BoFang`,`MP3BF;`);
        Generator.addSetup(`MP3BF.Huoquyinjiao`,`MP3BF.Huoquyinjiao(${SZ_YINJIAO});`);
    }

    //% block="语音模块 音量[OTP_yinliang]" blockType="command"
    //% OTP_yinliang.shadow="range" OTP_yinliang.params.min=1 OTP_yinliang.params.max=8 OTP_yinliang.defl=1

    export function OTPyuyin_yinliang(parameter: any, block: any) 
    {
        let OTP_yinliang = parameter.OTP_yinliang.code;

        Generator.addCode(`MP3BF.yinliang(${OTP_yinliang});`);
        
    }

    //% block="语音模块 设置[OTP_shezhi]" blockType="command"
    //% OTP_shezhi.shadow="dropdown" OTP_shezhi.options="OTP_shezhi" OTP_shezhi.defl="OTP_shezhi.1"

    export function OTPyuyin_shezhi(parameter: any, block: any) 
    {
        let OTP_shezhi = parameter.OTP_shezhi.code;

        Generator.addCode(`MP3BF.send_data(${OTP_shezhi});`);
        Generator.addCode(`delay(50);`);
    }

    //% block="播放 常用语音[BOFANG_CY]等待[DELAY]ms" blockType="command"
    //% BOFANG_CY.shadow="dropdownRound" BOFANG_CY.options="BOFANG_CY" BOFANG_CY.defl="BOFANG_CY.0"
    //% DELAY.shadow="number"  DELAY.defl="1000"
    export function OTPyuyin_BF(parameter: any, block: any) 
    {
        let BOFANG_CY = parameter.BOFANG_CY.code;
        let DELAY = parameter.DELAY.code;
        Generator.addCode(`MP3BF.send_data(${BOFANG_CY});`);
        Generator.addCode(`delay(${DELAY});`);
    }
    //% block="播放 天气/环境相关[BOFANG_TQ]等待[DELAY]ms" blockType="command"
    //% BOFANG_TQ.shadow="dropdownRound" BOFANG_TQ.options="BOFANG_TQ" BOFANG_TQ.defl="BOFANG_TQ.0"
    //% DELAY.shadow="number"  DELAY.defl="1000"
    export function OTPyuyin_BF_TQ(parameter: any, block: any) 
    {
        let BOFANG_TQ = parameter.BOFANG_TQ.code;
        let DELAY = parameter.DELAY.code;
        Generator.addCode(`MP3BF.send_data(${BOFANG_TQ});`);
        Generator.addCode(`delay(${DELAY});`);
    }
    //% block="播放 时间相关[BOFANG_SJ]等待[DELAY]ms" blockType="command"
    //% BOFANG_SJ.shadow="dropdownRound" BOFANG_SJ.options="BOFANG_SJ" BOFANG_SJ.defl="BOFANG_SJ.0"
    //% DELAY.shadow="number"  DELAY.defl="1000"
    export function OTPyuyin_BF_SJ(parameter: any, block: any) 
    {
        let BOFANG_SJ = parameter.BOFANG_SJ.code;
        let DELAY = parameter.DELAY.code;
        Generator.addCode(`MP3BF.send_data(${BOFANG_SJ});`);
        Generator.addCode(`delay(${DELAY});`);
    }
    //% block="播报 1万以内数字[SHUZI]间隔时间[DELAY]ms" blockType="command"
    //% SHUZI.shadow="number" SHUZI.defl="0"
    //% DELAY.shadow="number"  DELAY.defl="400"
    export function OTPyuyin_BF_SZ(parameter: any, block: any) 
    {
        let SHUZI = parameter.SHUZI.code;
        let DELAY = parameter.DELAY.code;
        Generator.addCode(`MP3BF.Bobaoshuzi(${SHUZI},${DELAY});`);
    }

    /*空行*/
    //% block="---"
    export function kong_hang_001() {

    }

    //--------------电位计模块-------------------//

    //% block="读取 旋转电位器[MN_YINJIAO]数据" blockType="reporter"
    //% MN_YINJIAO.shadow="dropdownRound" MN_YINJIAO.options="MN_YINJIAO" MN_YINJIAO.defl="MN_YINJIAO.A0"
    
    export function DianWeiQi(parameter: any, block: any) 
    {
        let MN_YINJIAO = parameter.MN_YINJIAO.code;

        Generator.addCode(`analogRead(${MN_YINJIAO})`);
    }

    //--------------灰度传感器模块模块-------------------//

    //% block="读取 灰度传感器[MN_YINJIAO]数据" blockType="reporter"
    //% MN_YINJIAO.shadow="dropdownRound" MN_YINJIAO.options="MN_YINJIAO" MN_YINJIAO.defl="MN_YINJIAO.A0"
    
    export function HuiDu(parameter: any, block: any) 
    {
        let MN_YINJIAO = parameter.MN_YINJIAO.code;

        Generator.addCode(`analogRead(${MN_YINJIAO})`);
    }

    //--------------声音传感器模块-------------------//

    //% block="声音传感器[SZ_YINJIAO]状态[YOUWU]" blockType="boolean"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% YOUWU.shadow="dropdownRound" YOUWU.options="YOUWU" YOUWU.defl="1"
    
    export function ShengYin(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let YOUWU = parameter.YOUWU.code;

        Generator.addCode(`digitalRead(${SZ_YINJIAO}) == ${YOUWU}`);
    }

    //--------------超声波传感器模块-------------------//

    //% block="读取 超声波距离(cm) Trig[trig]Echo[echo]Vcc T E Gnd" blockType="reporter"
    //% trig.shadow="dropdownRound" trig.options="trig" trig.defl="trig.A4"
    //% echo.shadow="dropdownRound" echo.options="echo" echo.defl="echo.A5"
    
    export function ChaoShengBo(parameter: any, block: any) 
    {
        let trig = parameter.trig.code;
        let echo = parameter.echo.code;

        Generator.addInclude('DFRobot_URM10', '#include <DFRobot_URM10.h>');
        Generator.addObject( `urm10`, `DFRobot_URM10`,`urm10;`);
        Generator.addCode(`urm10.getDistanceCM(${trig},${echo})`);
    }

    //--------------温湿度传感器模块-------------------//

    //% block="读取 温湿度传感器[SZ_YINJIAO][WenShiDu_DHT][WenShiDu]" blockType="reporter"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% WenShiDu_DHT.shadow="dropdownRound" WenShiDu_DHT.options="WenShiDu_DHT" WenShiDu_DHT.defl="WenShiDu_DHT.1"
    //% WenShiDu.shadow="dropdownRound" WenShiDu.options="WenShiDu" WenShiDu.defl="WenShiDu.getTemperature"
    export function WENSHIDU(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let WenShiDu_DHT = parameter.WenShiDu_DHT.code;
        let WenShiDu = parameter.WenShiDu.code;

        Generator.addInclude('DFRobot_DHT', '#include <DFRobot_DHT.h>');
        
        if(WenShiDu_DHT == 1)
        {
            Generator.addObject( `dht11_${SZ_YINJIAO}`, `DFRobot_DHT`,`dht11_${SZ_YINJIAO};`);
            Generator.addSetup(`dht11_${SZ_YINJIAO}.begin`,`dht11_${SZ_YINJIAO}.begin(${SZ_YINJIAO},DHT11);`);
            Generator.addCode(`dht11_${SZ_YINJIAO}.${WenShiDu}()`);
        }
        if(WenShiDu_DHT == 2)
        {
            Generator.addObject( `dht22_${SZ_YINJIAO}`, `DFRobot_DHT`,`dht11_${SZ_YINJIAO};`);
            Generator.addSetup(`dht22_${SZ_YINJIAO}.begin`,`dht22_${SZ_YINJIAO}.begin(${SZ_YINJIAO},DHT22);`); 
            Generator.addCode(`dht22_${SZ_YINJIAO}.${WenShiDu}()`);
        }
        
    }

    /*空行*/
    //% block="---"
    export function kong_hang_003() {

    }

    //--------------四位数码管模块-------------------//

    //% block="初始化 四位数码管 DIO[Dio]CLK[Clk]" blockType="command"
    //% Clk.shadow="dropdownRound" Clk.options="Clk" Clk.defl="Clk.A5"
    //% Dio.shadow="dropdownRound" Dio.options="Dio" Dio.defl="Dio.A4"
    export function TM1637_ChuShiHua(parameter: any, block: any) 
    {
        let Clk = parameter.Clk.code;
        let Dio = parameter.Dio.code;

        Generator.addInclude('SevenSegmentTM1637', '#include <SevenSegmentTM1637.h>');
        Generator.addInclude('SevenSegmentExtended', '#include <SevenSegmentExtended.h>');
        Generator.addObject( `display`, `SevenSegmentExtended`,`display(${Clk},${Dio});`);
        Generator.addSetup(`display.begin`,`display.begin();`);
    }
    //% block="数码管 设置亮度[TM1637_LiangDu]" blockType="command"
    //% TM1637_LiangDu.shadow="range"  TM1637_LiangDu.params.min=0 TM1637_LiangDu.params.max=100 TM1637_LiangDu.defl="50"
    export function TM1637_SZ_LiangDu(parameter: any, block: any) 
    {
        let TM1637_LiangDu = parameter.TM1637_LiangDu.code;
        Generator.addCode(`display.setBacklight(${TM1637_LiangDu});`);
    }
    //% block="数码管[TM1637_caozuo]" blockType="command"
    //% TM1637_caozuo.shadow="dropdownRound" TM1637_caozuo.options="TM1637_caozuo" TM1637_caozuo.defl="TM1637_caozuo.clear"
    export function TM1637_CaoZuo(parameter: any, block: any) 
    {
        let TM1637_caozuo = parameter.TM1637_caozuo.code;
        Generator.addCode(`display.${TM1637_caozuo}();`);
    }
    //% block="数码管 显示字符串[TM1637_XSZiFuChuan]" blockType="command"
    //% TM1637_XSZiFuChuan.shadow="string" TM1637_XSZiFuChuan.defl="0001"
    export function TM1637_XS_ZiFuChuan(parameter: any, block: any) 
    {
        let TM1637_XSZiFuChuan = parameter.TM1637_XSZiFuChuan.code;
        Generator.addCode(`display.print(${TM1637_XSZiFuChuan});`);
    }

    //% block="数码管 显示时间[TM1637_S]：[TM1637_F] 时钟点[TM1637_ShiZhongDian]" blockType="command"
    //% TM1637_S.shadow="range" TM1637_S.params.min=0 TM1637_S.params.max=23 TM1637_S.defl="12"
    //% TM1637_F.shadow="range" TM1637_F.params.min=0 TM1637_F.params.max=59 TM1637_F.defl="30"
    //% TM1637_ShiZhongDian.shadow="dropdownRound" TM1637_ShiZhongDian.options="TM1637_ShiZhongDian" TM1637_ShiZhongDian.defl="TM1637_ShiZhongDian.1"
    export function TM1637_XS_ShiJian(parameter: any, block: any) 
    {
        let TM1637_S = parameter.TM1637_S.code;
        let TM1637_F = parameter.TM1637_F.code;
        let TM1637_ShiZhongDian = parameter.TM1637_ShiZhongDian.code;    

        Generator.addCode(`display.printTime(${TM1637_S},${TM1637_F},${TM1637_ShiZhongDian});`);
    }

    /*空行*/
    //% block="---"
    export function kong_hang_004() {

    }

    //----------------颜色识别传感器模块-------------------//

    //% block="初始化 颜色传感器" blockType="command"
    
    export function Yan_se_chushihua(parameter: any, block: any) 
    {
        Generator.addInclude('LBXQ_2', '#include <LBXQ_2.h>');//统一分类到LBXQ
        Generator.addObject( `tcs34725`, `EM_TCS34725`,`tcs34725;`);
        Generator.addSetup(`tcs34725.begin`,`tcs34725.begin();`);
    }

    //% block="读取 颜色传感器[RGB]值" blockType="reporter"
    //% RGB.shadow="dropdownRound" RGB.options="RGB" RGB.defl="RGB.1"
    
    export function Yan_se_duqu_RGB(parameter: any, block: any) 
    {
        let RGB = parameter.RGB.code;
        switch(RGB)
        {
            case 'R':Generator.addCode(`tcs34725.getRedToGamma()`);break;
            case 'G':Generator.addCode(`tcs34725.getGreenToGamma()`);break;
            case 'B':Generator.addCode(`tcs34725.getBlueToGamma()`);break;
        }
    }
    //% block="颜色传感器 识别到[YAN_SE]精确度[YanSe_Jingque]" blockType="boolean"
    //% YAN_SE.shadow="dropdownRound" YAN_SE.options="YAN_SE" YAN_SE.defl="YAN_SE.1"
    //% YanSe_Jingque.shadow="range" YanSe_Jingque.params.min=0 YanSe_Jingque.params.max=50 YanSe_Jingque.defl=40
    export function Yan_se_shibie(parameter: any, block: any) 
    {
        let YAN_SE = parameter.YAN_SE.code;
        let YanSe_Jingque = parameter.YanSe_Jingque.code;
        switch(YAN_SE)
        {
            case '红色':Generator.addCode(`tcs34725.getRedToGamma()>${YanSe_Jingque}`);break;//30 //50更准
            case '绿色':Generator.addCode(`tcs34725.getGreenToGamma()>${YanSe_Jingque}`);break;//20
            case '蓝色':Generator.addCode(`tcs34725.getBlueToGamma()>${YanSe_Jingque}`);break;//30
        }
    }

    /*空行*/
    //% block="---"
    export function kong_hang_005() {

    }

    //----------------RGB灯模块-------------------//

    //% block="初始化 RGB灯 引脚[SZ_YINJIAO]灯总数[RGB_LED_SUM]" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% RGB_LED_SUM.shadow="number" RGB_LED_SUM.defl=3
    export function RGB_LED(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let RGB_LED_SUM = parameter.RGB_LED_SUM.code;
        Generator.addInclude('DFRobot_NeoPixel', '#include <DFRobot_NeoPixel.h>');
        Generator.addObject( `DFRobot_NeoPixel`, `DFRobot_NeoPixel`,`neoPixel_${SZ_YINJIAO};`);
        Generator.addSetup(`neoPixel_${SZ_YINJIAO}.begin`,`neoPixel_${SZ_YINJIAO}.begin(${SZ_YINJIAO},${RGB_LED_SUM});`);
    }
    //% block="设置 RGB灯 引脚[SZ_YINJIAO]亮度[RGB_liangdu]" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% RGB_liangdu.shadow="range"  RGB_liangdu.params.min=0  RGB_liangdu.params.max=255  RGB_liangdu.defl=255
    export function RGB_LED_laingdu(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let RGB_liangdu = parameter.RGB_liangdu.code;
        Generator.addCode(`neoPixel_${SZ_YINJIAO}.setBrightness(${RGB_liangdu});`);
    }

    //% block="RGB灯 引脚[SZ_YINJIAO]全部熄灭" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    export function RGB_LED_ximie(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        Generator.addCode(`neoPixel_${SZ_YINJIAO}.clear();`);
    }

    //% block="RGB灯 引脚[SZ_YINJIAO]灯号[RBG_0]到[RBG_1]显示颜色[RBG_COLOR]" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% RBG_0.shadow="number"  RBG_0.defl=0
    //% RBG_1.shadow="number"  RBG_1.defl=3
    //% RBG_COLOR.shadow="colorPalette" RBG_COLOR.params.column=7
                                                        /*column：表示将颜色数组用多少列排列。*/
    //% RBG_COLOR.params.colorsFunc="getColorsFunc_" 
                        /*colorsFunc：颜色回调函数，必须存在。*/
 
    export function RGB_LED_duogexianshi(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let RBG_0 = parameter.RBG_0.code;
        let RBG_1 = parameter.RBG_1.code;
        let RBG_COLOR = parameter.RBG_COLOR.code;

        Generator.addCode(`neoPixel_${SZ_YINJIAO}.setRangeColor(${RBG_0},${RBG_1},${RBG_COLOR});`);
    }

    //% block="红[RGB_Red]绿[RGB_Green]蓝[RGB_Blue]" blockType="reporter"
    //% RGB_Red.shadow="range" RGB_Red.params.min=0 RGB_Red.params.max=255 RGB_Red.defl=255
    //% RGB_Green.shadow="range" RGB_Green.params.min=0 RGB_Green.params.max=255 RGB_Green.defl=255
    //% RGB_Blue.shadow="range" RGB_Blue.params.min=0 RGB_Blue.params.max=255 RGB_Blue.defl=255
    export function RGB_LED_RGB(parameter: any, block: any) 
    {
        let RGB_Red = parameter.RGB_Red.code;
        let RGB_Green = parameter.RGB_Green.code;
        let RGB_Blue = parameter.RGB_Blue.code;
       // Generator.addObject( `uint32_t`, `uint32_t`,`rgbToColor(uint8_t r, uint8_t g, uint8_t b);`);
        Generator.addObject(`uint32_t`, `uint32_t`,'rgbToColor(uint8_t r, uint8_t g, uint8_t b){return (uint32_t)((((uint32_t)r<<16) | ((uint32_t)g<<8)) | (uint32_t)b);}');
        Generator.addCode(`rgbToColor(round(${RGB_Red}), round(${RGB_Green}), round(${RGB_Blue}))`);
        
    }

    //% block="RGB灯 引脚[SZ_YINJIAO]灯号[RBG_0]到[RBG_1]显示渐变颜色 色调从[RBG_COLOR0]到[RBG_COLOR1]" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% RBG_0.shadow="number"  RBG_0.defl=0
    //% RBG_1.shadow="number"  RBG_1.defl=3
    //% RBG_COLOR0.shadow="number" RBG_COLOR0.defl=1
    //% RBG_COLOR1.shadow="number" RBG_COLOR1.defl=360
 
    export function RGB_LED_jianbianse(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let RBG_0 = parameter.RBG_0.code;
        let RBG_1 = parameter.RBG_1.code;
        let RBG_COLOR0 = parameter.RBG_COLOR0.code;
        let RBG_COLOR1 = parameter.RBG_COLOR1.code;
        Generator.addCode(`neoPixel_${SZ_YINJIAO}.showRainbow(${RBG_0},${RBG_1},${RBG_COLOR0},${RBG_COLOR1});`);
    }

    //% block="RGB灯 引脚[SZ_YINJIAO][RGB_xh_yd][YiDong]单位" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% RGB_xh_yd.shadow="dropdownRound" RGB_xh_yd.options="RGB_xh_yd" RGB_xh_yd.defl="RGB_xh_yd.0"
    //% YiDong.shadow="number"  YiDong.defl=0
 
    export function RGB_LED_yidong(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let RGB_xh_yd = parameter.RGB_xh_yd.code;
        let YiDong = parameter.YiDong.code;

        if(RGB_xh_yd == 0)
        {
            Generator.addCode(`neoPixel_${SZ_YINJIAO}.shift(${YiDong});`);
        }
        else if(RGB_xh_yd == 1)
        {
            Generator.addCode(`neoPixel_${SZ_YINJIAO}.rotate(${YiDong});`);
        }   
    }

    //% block="RGB灯 引脚[SZ_YINJIAO]灯号[RBG_0]到[RBG_1]显示柱状图 当前值[RBG_00]最大值[RBG_01]" blockType="command"
    //% SZ_YINJIAO.shadow="dropdownRound" SZ_YINJIAO.options="SZ_YINJIAO" SZ_YINJIAO.defl="SZ_YINJIAO.2"
    //% RBG_0.shadow="number"  RBG_0.defl=0
    //% RBG_1.shadow="number"  RBG_1.defl=3
    //% RBG_00.shadow="number" RBG_00.defl=3
    //% RBG_01.shadow="number" RBG_01.defl=3
 
    export function RGB_LED_zhuzhuangtu(parameter: any, block: any) 
    {
        let SZ_YINJIAO = parameter.SZ_YINJIAO.code;
        let RBG_0 = parameter.RBG_0.code;
        let RBG_1 = parameter.RBG_1.code;
        let RBG_00 = parameter.RBG_00.code;
        let RBG_01 = parameter.RBG_01.code;
        Generator.addCode(`neoPixel_${SZ_YINJIAO}.showBarGraph(${RBG_0},${RBG_1},${RBG_00},${RBG_01});`);
    }

    /*空行*/
    //% block="---"
    export function kong_hang_006() {

    }

    //--------------------------LCD1602---------------------------------//
    
    //% block="初始化 LCD1602 地址[dizhi1602]" blockType="command"
    //% dizhi1602.shadow="number" dizhi1602.defl="0x27"
    export function LCD1602_CSH(parameter: any, block: any) 
    {
        let dizhi1602 = parameter.dizhi1602.code;

        Generator.addInclude('DFRobot_LiquidCrystal_I2C', '#include <DFRobot_LiquidCrystal_I2C.h>');//统一分类到LBXQ
        Generator.addObject( `lcd1602`, `DFRobot_LiquidCrystal_I2C`,`lcd1602;`);
        Generator.addSetup(`lcd1602.begin`,`lcd1602.begin(${dizhi1602});`);
    }

    //% block="LCD1602清屏" blockType="command"
    export function LCD1602_QingPing(parameter: any, block: any) 
    {
        Generator.addCode(`lcd1602.clear();`);
    } 

    //% block="LCD1602在[Y1602]显示[xianshi1602]" blockType="command"
    //% Y1602.shadow="dropdown" Y1602.options="Y1602" Y1602.defl="Y1602.1"
    //% xianshi1602.shadow="string" xianshi1602.defl="hello"
    export function LCD1602_Hxs(parameter: any, block: any) 
    {
        let Y1602 = parameter.Y1602.code;
        let xianshi1602 = parameter.xianshi1602.code;

        Generator.addCode(`lcd1602.printLine(uint32_t(!(${Y1602})), ${xianshi1602});`);
        //Y与下面模块坐标显示中相反，所以此处使用取反，简化菜单
    }

    //% block="LCD1602在坐标 X[X1602]Y[Y1602]显示[xianshi1602]" blockType="command"
    //% X1602.shadow="range"   X1602.params.min=0    X1602.params.max=15    X1602.defl=0
    //% Y1602.shadow="dropdown" Y1602.options="Y1602" Y1602.defl="Y1602.1"
    //% xianshi1602.shadow="string" xianshi1602.defl="hello"
    export function LCD1602_xs(parameter: any, block: any) 
    {
        let X1602 = parameter.X1602.code;
        let Y1602 = parameter.Y1602.code;
        let xianshi1602 = parameter.xianshi1602.code;

        Generator.addCode(`lcd1602.print(uint32_t(${X1602}),uint32_t(${Y1602}), ${xianshi1602});`);
    }

}